package com.ruoyi.project.labapprove.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.project.lab.domain.LabAppointmentDto;
import com.ruoyi.project.labapprove.domain.ApproveParam;
import com.ruoyi.project.labapprove.service.LabApproveService;
import com.ruoyi.project.property.domain.LabProperty;
import com.ruoyi.project.property.service.ILabPropertyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 【预约审批】Controller
 * 
 * @author ruoyi
 * @date 2019-11-16
 */
@Controller
@RequestMapping("labapprove")
public class LabApproveController extends BaseController
{
    private String prefix = "system/labapprove";

    @Autowired
    private LabApproveService labApproveService;

    @RequiresPermissions("system:labapprove:view")
    @GetMapping()
    public String property()
    {
        return prefix + "/labapprove";
    }

    /**
     * 查询【实验室管理员：预约审批】列表
     */
    @RequiresPermissions("system:labapprove:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ApproveParam approveParam)
    {
        startPage();
        List<LabAppointmentDto> labAppointmentDtos =labApproveService.selectList(approveParam);
        return getDataTable(labAppointmentDtos);
    }

    /**
     * 实验室管理员：预约审批：审核成功
     * @param id
     * @return
     */
    @GetMapping("/audit")
    @ResponseBody
    public AjaxResult audit(Long id)
    {
        return labApproveService.audit(id);

    }/**
     * 实验室管理员：预约审批：审核拒绝
     * @param id
     * @return
     */
    @GetMapping("/auditRefuse")
    @ResponseBody
    public AjaxResult auditRefuse(Long id)
    {
        return labApproveService.auditRefuse(id);

    }
}
